package com.hg.transaction;

import com.hg.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: skh
 * @Date: 2019/9/10 14:09
 * @Description:
 */
@RestController
@Slf4j
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/add")
    public void add() {
        try {
            studentService.add();
            log.info("事务已提交");
        } catch (Exception e) {
            log.info("捕捉");
        }
    }

    @RequestMapping("/list")
    public R list() {
        List<Student> list = studentService.list();
        return R.success(list);
    }
}
